$(function(){
	//按钮一
	var fuText;
    var searchb = function() {   
    	url = "/modules/report/user/baseInfoJson.html";
    	ajaxUrl2(url);
    }
    
    var ajaxUrl2 = function(url){
		$.ajax({
			url:url + "?randomTime=" + (new Date()).getTime(),
			type:"get",
			dataType:"json",
			cache:false,
			success:function(data){
				var option;
				option1 = {
					title : {
					    text: '用户年龄分布',
					    x:'center',
		            	y:'top',
		            	padding:30,
		            	textStyle:{
							fontSize: 24, 
							fontWeight: 'bolder'	
		            	},
		            	subtext:fuText
					},
					calculable : true,
					legend: {
				        orient : 'vertical',
				        x : '80%',
				        y : 'center',
				        data:['20岁以下','20-30岁','30-40岁','40-50岁','50岁以上']
				    },
					tooltip : {
					    show: true,
					    formatter: "{a} <br/>{b} : {c} ({d}%)"
					},
					series : [
					    {
					        name:'年龄分布',
					        type:'pie',
					        radius : '50%',
					        center: ['50%', '65%'],
					        data:[
					            {value:data.arr[0],name:'20岁以下'},
					            {value:data.arr[1],name:'20-30岁'},
					            {value:data.arr[2],name:'30-40岁'},
					            {value:data.arr[3],name:'40-50岁'},
					            {value:data.arr[4],name:'50岁以上'}
					        ]
					    }
					]
				}
				
				option2 = {
					title : {
					    text: '用户性别分布',
					    x : 'center',
				        y : 'top',
		            	padding:30,
		            	textStyle:{
							fontSize: 24, 
							fontWeight: 'bolder'	
		            	},
		            	subtext:fuText
					},
					calculable : true,
					legend: {
				        orient : 'vertical',
				        x : '80%',
				        y : 'center',
				        data:['男','女','保密']
				    },
					tooltip : {
					    show: true,
					    formatter: "{a} <br/>{b} : {c} ({d}%)"
					},
					series : [
					    {
					        name:'性别分布',
					        type:'pie',
					        radius : '50%',
					        center: ['50%', '65%'],
					        data:[
					            {value:data.arr[5],name:'男'},
					            {value:data.arr[6],name:'女'},
					            {value:data.arr[7],name:'保密'}
					        ]
					    }
					]
				}
				
				var dataVal = [];
				for (var i = 0; i < data.provinceCounts.length; i++) {
					dataVal.push({name: data.provinces[i],value: data.provinceCounts[i]});
				};
				option3 = {
				    title : {
				        text: '用户地区分布',
				        x:'center',
				        padding:30,
		            	textStyle:{
							fontSize: 24, 
							fontWeight: 'bolder'	
		            	},
				        subtext:fuText
				    },
				    tooltip : {
				    	show:true,
				        trigger: 'axis'
				    },
				    legend: {
				        orient: 'vertical',
				        x:'left',
				        data:['人数（人）']
				    },
				    dataRange: {
				        min: 0,
				        max: 25000,
				        x: 'left',
				        y: 'bottom',
				        text:['高','低'],           // 文本，默认为数值文本
				        calculable : true
				    },
				    roamController: {
				        show: true,
				        x: 'right',
				        mapTypeControl: {
				            'china': true
				        }
				    },
				    series : [
				        {
				            name: '人数（人）',
				            type: 'map',
				            mapType: 'china',
				            roam:true,
				            itemStyle:{
				                normal:{label:{show:true}},
				                emphasis:{label:{show:true}}
				            },
				            data:dataVal
				        }
				    ]
				};
		        
				document.getElementById('investTablea').style.display = "inline-block";
				document.getElementById('investTableb').style.display = "inline-block";
				document.getElementById('investTablec').style.display = "inline-block";
				echarts.init(document.getElementById('investTablea')).setOption(option1); 
		        echarts.init(document.getElementById('investTableb')).setOption(option2);
		        echarts.init(document.getElementById('investTablec')).setOption(option3);
			}
		});
	};
	
	searchb();
});